﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;

namespace backend_wcf
{
    [ServiceContract]
    public interface IService
    {
        /// <summary>
        /// Hello World method
        /// </summary>
        /// <returns>Hello World!!</returns>
        [OperationContract]
        string HelloWorld();

        /// <summary>
        /// Method to test getting data from DB
        /// to be removed before release
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        DataSet TestDB();

        /// <summary>
        /// Inserts a new row in the specified table with the specified values
        /// </summary>
        /// <param name="tableName">The table to insert into</param>
        /// <param name="values">A dictionarty with column name and value pairs</param>
        [OperationContract]
        void addData(string tableName, Dictionary<string, Object> values);

        /// <summary>
        /// Inserts a new column in a table in the Database.
        /// </summary>
        /// <param name="tableName">Table that the column will be inserted into</param>
        /// <param name="columnName">Name of the new column</param>
        /// <param name="dbType">The Type the column will be</param>
        [OperationContract]
        void createColumn(string tableName, string columnName, string dbType);

        /// <summary>
        /// Creates a new Table in the Database
        /// </summary>
        /// <param name="name">Name on the new Table</param>
        [OperationContract]
        void createTable(string name);

        /// <summary>
        /// Method for getting data from a speciefied Table in the Database.
        /// There is a logical expression parameter that can be ommited.
        /// </summary>
        /// <param name="tableName">which table to get data from</param>
        /// <param name="logic_expression">a WHERE clausule, can be NULL</param>
        /// <returns>A DataSet containing the result</returns>
        [OperationContract]
        DataSet getData(string name, string logic_expression);

        /// <summary>
        /// gets the column names and types for a table
        /// </summary>
        /// <param name="tableName">Name of the table</param>
        /// <returns></returns>
        [OperationContract]
        List<string> getStructure(string tableName);

        /// <summary>
        /// Gets a list of all Tables in the database
        /// </summary>
        /// <returns>string array of table names</returns>
        [OperationContract]
        List<string> getTables();

        /// <summary>
        /// Delete a row in the selected table with selected index.
        /// </summary>
        /// <param name="tableName">The table to remove from</param>
        /// <param name="id">id of row to remove</param>
        [OperationContract]
        void deleteData(string tableName, int id);
    }
}
